from tornado.httputil import HTTPServerRequest
from tornado.web import RequestHandler

class IndexHandler(RequestHandler):
    def get(self):
        data = {
            'msg': 'Hi, Disen!西安欢迎您',
            'error_msg': None,
            'age': 90,
            'menus': ['主页', '最新推荐', '热门话题', '个人中心'],
            'code':'<h3>hi,我是图片：8 > 5</h3>'
        }
        self.render('index.html', **data)

    def post(self):
        # 新增数据
        name = self.get
        self.write('<h3>这是POST请求方式</h3>')

    def put(self):
        # 新增数据
        # 读取表单参数
        # 1、
        # name = self.get_argument('name')
        # city = self.get_argument('city')

        # 2、推荐
        name = self.get_body_argument('name')
        city = self.get_body_argument('city')
        self.write('<h3>这是PUT请求方式:%s %s</h3>' % (name,city))


    def delete(self, *args, **kwargs):
        # 新增数据
        self.write('<h3>这是DELETE请求方式</h3>')